package com.example.demo.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.demo.dto.ResponseDTO;
import com.example.demo.mapper.UserBookMapper;
import com.example.demo.mapper.UserMapper;
import com.example.demo.model.User;
import com.example.demo.model.UserBook;
import com.example.demo.model.UserRole;
import com.example.demo.service.AdminService;
import com.example.demo.service.impl.AdminServiceImpl;
//import com.example.demo.util.JwtTokenUtil;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.data.domain.PageRequest;
//import org.springframework.http.ResponseEntity;
//import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
//import org.springframework.security.crypto.password.PasswordEncoder;
import java.util.List;
@RestController
@RequestMapping("/api/admin")
//@PreAuthorize("hasRole('ADMIN')") // 类级别权限控制
@Api(tags = "管理员接口")
public class AdminController {

    @Autowired
    private AdminServiceImpl adminService;

    @GetMapping("/borrow-records")
    @Operation(summary = "获取所有借书记录")
    public Page<UserBook> getAllRecords(
            @RequestParam(defaultValue = "0") int page,
            @RequestParam(defaultValue = "10") int size) {
        return adminService.getAllBorrowRecords(page, size);
    }
}



